<?php

class Login extends Controller{
	
	public function main(){
		if(isset($_POST['entrar'])){
			$email = $_POST['email'];
			$senha  = $_POST['senha'];
			$this->model->setEmailUser($email);
			$this->model->setPassUser($senha);
			$resLogin = $this->model->loadEntrar();
			if($resLogin==1){
				$obj = $this->model->load();
				Session::init();
				Session::set('id_user',$obj->getIdUser());
				Session::set('user',$obj->getNameUser());
				Session::set('logged',true);
				header("location:".AGENDA);
			} else {
				$this->view->assign('msgLogin','Acesso negado');
			}
		}
		$css = array('validationEngine.jquery.css');
		$this->view->assign('css',$css);
		$js = array('jquery.validationEngine.js','jquery.maskedinput.min.js');
		$this->view->assign('js',$js);
		$this->view->assign('titulo','Página Login');
		$this->view->render('login/index');
	}

}

?>